package cn.edu.usst.cs.goldfish.booking.meetingroom.service.impl;

import cn.edu.usst.cs.goldfish.booking.meetingroom.model.MeetingSlot;
import cn.edu.usst.cs.goldfish.booking.meetingroom.mybatis.MeetingSlotMapper;
import cn.edu.usst.cs.goldfish.booking.meetingroom.service.MeetingSlotService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.List;

@Service
public class MeetingSlotServiceImpl implements MeetingSlotService {

    private final MeetingSlotMapper meetingSlotMapper;

    public MeetingSlotServiceImpl(MeetingSlotMapper meetingSlotMapper) {
        this.meetingSlotMapper = meetingSlotMapper;
    }

    @Override
    public List<MeetingSlot> getSlotsByMeetingId(Long meetingId) {
        return meetingSlotMapper.selectList(
                new QueryWrapper<MeetingSlot>().eq("meeting_id", meetingId)
        );
    }

    @Override
    public List<MeetingSlot> getSlotsByRoomIdAndDate(Long roomId, LocalDateTime date) {
        return meetingSlotMapper.selectList(
                new QueryWrapper<MeetingSlot>()
                        .eq("room_id", roomId)
                        .eq("date", date.toLocalDate())

        );
    }
}
